﻿@model TomNet.App.Model.DB.Options
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>OptionsEdit</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="~/lib/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="~/css/font.css">
    @* <script src="~/jquery/dist/jquery.min.js"></script>*@
    <script src="~/lib/layui/layui.js" charset="utf-8"></script>
    <style>
        .layui-input-block {
            width: 210px;
        }

            .layui-input-block.big {
                width: 545px;
            }

        .layui-anim.layui-anim-upbit {
            max-height: 140px;
        }

        textarea {
            height: 76px !important;
            resize: none
        }
    </style>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body">

                        <form class="layui-form" action="">
                            <input type="hidden" id="id" name="id" value="@Model.Id" />
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">参数名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" size="24" id="names" name="names" value="@Model.Name" disabled placeholder="请输入参数名称" required lay-verify="required" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">参数值</label>
                                    <div class="layui-input-block">
                                        <input type="text" size="24" id="value" name="value" value="@Model.Value" oninput="value=value.replace(/[^\d.]/g,'')" placeholder="请输入参数值" required lay-verify="required" autocomplete="off" class="layui-input">
                                    </div>
                                </div>
                            </div>                            
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">参数说明</label>
                                    <div class="layui-input-block big">
                                        <textarea id="remark" name="remark" style="resize:none" placeholder="请输入参数说明" autocomplete="off" class="layui-input">@Model.Remark</textarea>
                                    </div>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button type="button" class="layui-btn" lay-submit lay-filter="form">立即提交</button>
                                    <button type="reset" class="layui-btn layui-btn-danger" style="width:100px;">重置</button>
                                </div>
                            </div>
                        </form>

                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['layer', 'form'], function () {
            var $ = layui.$;
            var form = layui.form;
            var layer = layui.layer;           
            form.on('submit(form)', function (data) {
                var id = $('#id').val().trim();
                var Name = $('#names').val().trim(); 
                var value = $('#value').val().trim(); 
                var Explain = $('#remark').val().trim();                
                $.ajax({
                    type: 'POST',
                    url: '/Options/OptionsEdit',
                    data: { Id: id, Name: Name, Value: value, Remark: Explain },
                    datatype: 'json',
                    success: function (data) {
                        if (data.type == 200) {
                            layer.alert(data.content, { icon: 6 }, function () {
                                closeself();
                            });

                        } else {
                            layer.alert("修改失败，或者权限不够", { icon: 5 });
                        }
                    }
                });
                return false;
            });
            var closeself = function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        });
    </script>
</body>
</html>
